package de.cau.apo.problems.binpacking;

/**
 * This class represents an item for the bin packing problem.
 * It just consists of an fixed index and of an fixed size.
 * 
 * @author Marius Richter
 *
 */
public class Item {

	// ########### properties ###########
	
	/** the index of this item */
	public final int index;
	/** the size of this item */
	public final int size;
	
	// ########### initialization ###########
	
	/**
	 * Creates a new item object.
	 * @param index the index for this item
	 * @param size the size for this item
	 */
	public Item(int index, int size) {
		this.index = index;
		this.size = size;
	}
	
	// ########### getter/setter ###########
	
	/**
	 * @return the index of this item
	 */
	public int getIndex() {
		return index;
	}
	
	/**
	 * @return the size of this item
	 */
	public int getSize() {
		return size;
	}

	// ########### overriding toString()###########
	
	@Override
	public String toString() {
		return "Item [index=" + index + ", size=" + size + "]";
	}
	
	// ########### overriding equality methods ###########

	@Override
	public int hashCode() {
		return index;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Item other = (Item) obj;
		if (index != other.index)
			return false;
		if (size != other.size)
			return false;
		return true;
	}
	
}
